<?php

//微信access_token
function wx_access_token(){
	$access_token=S('wx_access_token');
	if(!$access_token){
		$get_token=tokens();//获取token
		$data['access_token']=$get_token;
		$data['time']=time();

		if($get_token){
			S('wx_access_token',$data,5400);
			return $get_token;
		}else{
			return false;	
		}
	}else{
		$new_time=time()-5400;
		if($access_token['time']<=$new_time){
			$get_token=tokens();//获取token
			$data['access_token']=$get_token;
			$data['time']=time();
			if($get_token){
				S('wx_access_token',$data,5400);
				return $get_token;
			}else{
				return false;	
			}
		}else{
			return $access_token['access_token'];
		}
	}
}





